<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use App\Constants\Business;
use App\Constants\ErrorCode;
use App\Constants\RedisKey;
use Hyperf\Config\Annotation\Value;
use Hyperf\Context\Context;
use function Hyperf\Config\config;
use App\Log;

use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use OpenApi\Annotations as OA;
use Hyperf\ApiDocs\Annotation\Api;
use Hyperf\ApiDocs\Annotation\ApiOperation;
use Hyperf\HttpServer\Annotation\PostMapping;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\DTO\Type\PhpType;
use Hyperf\HttpServer\Annotation\Middleware;
use Hyperf\HttpServer\Annotation\AutoController;
use Phper666\JWTAuth\Middleware\JWTAuthDefaultSceneMiddleware;
use App\Middleware\ApiResponseMiddleware;
use App\Middleware\JWTAuthMiddleware;
use Hyperf\Di\Annotation\Inject;
use function L1n6yun\HyperfJwt\auth;

use L1n6yun\HyperfJwt\Annotation\Auth;

use App\Model\UserModel;

#[Controller(prefix: '/')]
#[Api(tags: 'Index管理控制器', position: 1)]
class IndexController extends AbstractController
{

    #[ApiOperation(summary: '健康检查接口')]
    #[GetMapping(path: 'health')]
    public function health()
    {
        return "OK";
    }

    #[ApiOperation(summary: 'Index接口')]
    #[Middleware(ApiResponseMiddleware::class)]
    public function index()
    {
        $user = $this->request->input('user', 'Hyperf');
        $method = $this->request->getMethod();
        return [
            'method' => $method,
            'message' => "Hello {$user}.",
        ];
    }

}
